{include file="Public:header" /}
<style>
	.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{
		padding:0px 5px;
		text-align: center; 
		vertical-align: middle!important;
	}
</style>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>申请列表</h5>
						<div class="ibox-tools" style="margin-top: -6px;">
						<a href="__MODULE__/{$Think.CONTROLLER_NAME}/{$Think.ACTION_NAME}" class="btn btn-primary"><i class="fa fa-refresh"></i> 刷新</a>
						</div>
					</div>
					<div class="ibox-content">
						<div class="row">
						<div class="col-sm-3">
							<!-- <a href="__URL__/addApply?act=add" class="btn btn-primary">
								<span class="fa fa-plus"></span>
								添加会员
							</a> -->
						</div>
						<form class="form-inline" action="__URL__/applyList" method="get">
								<div class="col-sm-9">
		                                <div class="input-group col-sm-3  pull-right">
			                                    <input type="text" name="full_name" placeholder="姓名" class="input-sm form-control"> 
			                                    <span class="input-group-btn">
			                                      <button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
			                                    </span>
		                                </div>
		                                
		                                <div class="input-group col-sm-2 pull-right">
											  <input type="text" name="phone_number" placeholder="手机号码" class="input-sm form-control select_no_border"> 
                                   		</div>
                                   		
                                   		 <div class="input-group col-sm-2 pull-right">
											  <input type="text" name="email" placeholder="邮箱" class="input-sm form-control select_no_border"> 
                                   		</div>

		                                <div class="input-group col-sm-2 pull-right select_width">
											<select name="apply_type" class="input-sm form-control select_no_border">
											 	<option value="">申请类型</option>
		                                        <option value="3">副会长</option>
		                                        <option value="4">理事</option>
		                                        <option value="5">国旗文化</option>
		                                        <option value="6">军事运动</option>
		                                        <option value="7">国防传媒</option>
		                                        <option value="8">军事警觉</option>
		                                    </select>
                                   		</div>
                                   		
                                   		 <div class="input-group col-sm-2 pull-right select_width">
											<select name="status" class="input-sm form-control select_no_border">
											 	<option value="">审核状态</option>
		                                        <option value="1">待审核</option>
		                                        <option value="2">已通过</option>
		                                        <option value="3">不通过</option>
		                                    </select>
                                   		</div>
                                   		
                                   		<!-- <div class="input-group col-sm-2 pull-right">
											 <select name="category" class="input-sm form-control select_no_border">
											 	<option value="">活动分类</option>
		                                       {foreach name="category" item="category" key="k"}
		                                        <option value="{$category['id']}">{$category['name']}</option>
		                                       {/foreach}
		                                    </select>
                                   		</div> -->
	                                
	                            </div>
	                     </form>  
						</div>
						
						<br />
						
						<div class="table-responsive">
						<form action="__URL__/operate" method="post" id="operate_form">	
							<table class="table table-bordered table-hover"
								id="categoryTable">
								<thead>
									<tr class="active">
									<th><input onclick="choosebox(this)" type="checkbox" /></th>
									<th height="40">编号</th>
									<th>姓名</th>
									<th>申请类型</th>
									<th>单位名称</th>
									<th>手机号码</th>
									<th>邮箱</th>
									<th>证件照</th>
									<th>证明材料</th>
									<th>备注</th>
									<th>审核状态</th>
									<th width="80">申请时间</th>
									<!-- <th>审核状态</th>  -->
									<!-- <th>浏览量</th> 
									<th width="10%">开始时间</th>
									<th width="10%">结束时间</th> -->
									<th width="100">操作</th>
									</tr>
								</thead>
								<tbody>
									{foreach name="apply" item="apply"}
									<tr>
									<td><input type="checkbox" name="apply_id[]" value="{$apply['id']}" /></td>
									<td>{$apply['id']}</td>
									<td>{$apply['full_name']}</td>
									<td>
										{switch name="apply['apply_type']"}
										    {case value="3"}副会长{/case}
										    {case value="4"}理事{/case}
										    {case value="5"}国旗文化{/case}
										    {case value="6"}军事运动{/case}
										    {case value="7"}国防传媒{/case}
										    {case value="8"}军事警觉{/case}
										 {/switch}
									</td>
									<td>{$apply['company']}</td>
									<td>{$apply['phone_number']}</td>
									<td>{$apply['email']}</td>
									<td><a target="_blank" href="{$apply['card_img']}"><img alt="image" style="width:50px;height:50px;" src="{$apply['card_img']}"></a></td>
									<td><a target="_blank" href="{$apply['prove_img']}"><img alt="image" style="width:50px;height:50px;" src="{$apply['prove_img']}"></a></td>
									<td><p title="{$apply['note']}" style="width:100px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{$apply['note']|htmlspecialchars_decode}</p></td>
									<td>
										{switch name="apply['status']"}
										    {case value="1"}待审核{/case}
										    {case value="2"}已通过{/case}
										    {case value="3"}不通过{/case}
										 {/switch}
									</td>
									<td>{$apply['add_time']|date="Y-m-d",###}</td>
									<!-- <td>
										{switch name="users['trial_status']"}
										    {case value="1"}待审核 {/case}
										    {case value="2"}通过{/case}
										    {case value="3"}不通过{/case}
										 {/switch}
									</td> -->
									<!-- <td>{$activity['browse_number']}</td>
									<td>{$activity['start_time']|date="Y-m-d H:i:s",###}</td>
									<td>{$activity['end_time']|date="Y-m-d H:i:s",###}</td> -->
										<td class="center">
										<!-- <button class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="标为垃圾邮件"><i class="fa fa-trash-o"></i>
                       					 </button> -->
											 <div class="dropdown">
												<button class="btn btn-primary dropdown-toggle"
													type="button" id="dropdownMenu1" data-toggle="dropdown"
													aria-haspopup="true" aria-expanded="true">
													操作
													<span class="caret"></span>
												</button>
												<ul class="dropdown-menu" style="min-width: 90px;" aria-labelledby="dropdownMenu1">
													<li>
														<a role="button" class="btn btn-primary"
															style="margin-bottom: 0px;" 
															href="__URL__/addApply?id={$apply['id']}&act=edit">
															<span class="fa fa-edit"></span>
															查看
														</a>
													</li>
													<li>
														<a role="button" class="btn btn-danger"
															style="margin-bottom: 0px;"
															onclick="deleteApply(this,{$apply['id']})" href="javascript:void(0);">
															<span class="fa fa-trash-o"></span>
															删除
														</a>
													</li>
												</ul>
											</div> 
										</td>
									</tr>
									{/foreach}
								</tbody>
							</table>
							<div class="col-sm-12" style="padding:0px;">
								<div class="col-sm-4" style="padding-left:0px;"> 
									<select id="operate" name="operate" class="input-sm form-control pull-left" style="width:100px;margin-right: 5px;">
													 	<option value="0">选择操作</option>
				                                        <option value="ok_status">通过</option>
				                                        <option value="not_status">不通过</option>
				                                        <option value="del">删除</option>
				                     </select>
				                     <button tpye="button"  class="btn btn-primary pull-left"> 确认</button>
			                    </div>
								<div class="col-sm-8" style="padding:0px;">
								  <ul class="pagination  pull-right">
								    {$page}
								  </ul>
								</div>
							</div>	
						</form>
						</div>
						
					</div>
				</div>
			</div>
		</div>
	</div>
<script>
/* var h=1;
function all_check(){
	if(h==1){
		$("input[name='rule_id[]']").each(function() {  
	         $(this).prop("checked", true); 
	    }); 
		h=2;
	}else if(h==2){
		$("input[name='rule_id[]']").each(function() { 
            $(this).prop("checked", false); 
    	}); 
		h=1;
	}
} */

function choosebox(o){
    var vt = $(o).is(':checked');
    if(vt){
        $('input[type=checkbox]').prop('checked',vt);
    }else{
        $('input[type=checkbox]').removeAttr('checked');
    }
}
</script>


<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
		<div class="modal-content">
		<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title" id="myModalLabel">添加商品</h4>
						</div>
						<div class="modal-body">
						<!-- class都是bootstrap定义好的样式，验证是根据input中的name值 -->
						<form action="__URL__/addShop" method="post" id="defaultForm">

						<div class="form-group">
						<label for="categoryName">商品名称</label>
						<input type="text" name="shop_name" style="border-radius: 4px;"
								id="categoryName" class="form-control" />
								</div>

								<div class="form-group">
								<label for="categoryTitle">商品地址</label>
								<input type="text" name="shop_address" style="border-radius: 4px;"
								id="categoryTitle" class="form-control" />
								</div>

								<div class="form-group">
								<label for="categoryKeywords">商品电话</label>
								<input type="text" name="shop_tel" style="border-radius: 4px;"
								id="categoryKeywords" class="form-control" />
								</div>

								<div class="form-group">
								<label for="categoryDescription">商品描述</label>
								<textarea name="shop_description" style="border-radius: 4px;"
								class="form-control" id="categoryDescription" /></textarea>
								</div>

						<div class="form-group">
								<label for="shopTel">地铁地址</label>
										<input type="text" name="metro_address" style="border-radius: 4px;"
										id="shopTel" class="form-control" />
										</div>

						<div class="form-group">
								<label for="shopTel">商品坐标</label>
										<input type="text" name="shop_coord" style="border-radius: 4px;"
										id="shopTel" class="form-control" />
										</div>

						<div class="modal-footer" id="parent_id">
								<button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
										<button type="submit" class="btn btn-primary">提交</button>
										</div>
										</form>
										</div>
										</div>
		</div>
	</div>
	
	<!-- 加载动画 -->
<!-- <div  class="spiner-example">
<div class="sk-spinner sk-spinner-wave">
<div class="sk-rect1"></div>
<div class="sk-rect2"></div>
<div class="sk-rect3"></div>
<div class="sk-rect4"></div>
<div class="sk-rect5"></div>
</div>
</div> -->
	<!-- Modal -->

{include file="Public:footer" /}

	<script>
$(document).ready(function() {
    /**
     * 下面是进行插件初始化
     * 你只需传入相应的键值对
     * */
    $('#defaultForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {/*输入框不同状态，显示图片的样式*/
            	  valid: 'glyphicon glyphicon-ok',
                  invalid: 'glyphicon glyphicon-remove',
                  validating: 'glyphicon glyphicon-refresh'
            },
            fields: {/*验证*/
            	shop_name: {/*键名username和input name值对应*/
                    message: '商品名称验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品名称不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品名称长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_address: {/*键名username和input name值对应*/
                    message: '商品地址验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品地址不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品地址长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_tel: {/*键名username和input name值对应*/
                    message: '商品电话验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品电话不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品电话长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_description: {/*键名username和input name值对应*/
                    message: '商品描述验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品描述不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品描述长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_coord:{/*键名username和input name值对应*/
                    message: '商品坐标验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品坐标不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品坐标长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                metro_address:{/*键名username和input name值对应*/
                    message: '地铁地址验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '地铁地址不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '地铁地址长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                }
               
            }
            // 还有一个比较常用的就是submitHandler属性，它对应着提交按钮的事件方法。
            // submitHandler: function (validator, form, submitButton) {
                //alert("submit");
               /*  var menu_name = $("input[name='menu_name']").val();
                var link = $("input[name='link']").val();
                var ico = $("input[name='ico']").val();
                $.ajax({
                    url : '__URL__/addMenu',
                    type : 'get',
                    data : {'menu_name' : menu_name, 'link' : link, 'ico':ico},
                    dataType : 'json',
                    success : function(data){
                      alert(data.message);
                    }
                }); */
           // }
        });
});

//修改菜单
/* function editGroup(obj){
	var group_id = $(obj).attr('group_id');
	var group_title = $(obj).attr('group_title');
	$('#myModal').modal('show');
	$("#defaultForm").attr('action','__URL__/editUserGroup?id='+group_id);
	$("input[name='title']").val(group_title);
} */

// window.onload=setTotal();	

//删除
function deleteApply(obj, id){
	layer.confirm('确定要删除数据吗',{btn:['确认','取消'], icon:3, closeBtn: 2 },function(index){
		$.ajax({
			url : '__URL__/deleteApply',
			data : {'id':id},
			type : 'get',
			dataType : 'json',
			async : false,   //取消同步，执行完之后再往下执行
			success : function(data){
				if(data.status == 1){				
					layer.msg(''+data.message+'',{icon:1,time:1000});
					$(obj).parent('li').parent('ul').parent('div').parent('td').parent('tr').remove();
				}else if(data.status == 2){
					layer.msg(''+data.message+'',{icon:2,time:1000});
				}
			}
		});
	});	
}
</script>
<script>
    //操作
    $('#operate_form').submit(function(){
    	var op_type = $("select[name='operate']").val();
        if(op_type == 0){
    		layer.msg('请选择操作', {time: 1000});   //alert('请选择操作');
            return false;
        }
        var selected = $("input[name='apply_id[]']:checked");
        if(selected.length < 1){
    		layer.msg('请选择记录', {time: 1000}); //            alert('请选择项目');
    		return false;
        }
        
    });
</script>
</body>
</html>
